package com.android.fragmentdemo
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
import androidx.appcompat.widget.AppCompatTextView
import com.android.fragmentdemo.databeans.DataFactoryIp
import com.android.fragmentdemo.databinding.ActivityAutoWrapViewGroupBinding
import com.hengfoxwolf.commonbase.base.BaseActivity

class AutoWrapViewGroupActivity : BaseActivity<ActivityAutoWrapViewGroupBinding>() {

    override fun getLayoutId(): Int = R.layout.activity_auto_wrap_view_group

    override fun init(savedInstanceState: Bundle?) {
        val dataSet = DataFactoryIp.createStrDataSet()
        val loadCount = 10.coerceAtMost(dataSet.size)
        val newDataSet = dataSet.subList(0, loadCount)
        for (i in 0.until(newDataSet.size)) {
            /*val view = LayoutInflater.from(this@AutoWrapViewGroupActivity)
                .inflate(R.layout.rv_study_item_layout, null, false)
            val textView = view.findViewById<AppCompatTextView>(R.id.rv_study_item)*/

            val view = LayoutInflater.from(this@AutoWrapViewGroupActivity)
                .inflate(R.layout.auto_wrap_item_layout, null, false)
            val textView = view.findViewById<AppCompatTextView>(R.id.auto_wrap_item)

            textView.text = newDataSet[i]

            //val layoutParams0 = ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT)
            //val layoutParams1 = MarginLayoutParams(MarginLayoutParams.WRAP_CONTENT,MarginLayoutParams.WRAP_CONTENT)
            //mBinding.autoWrapViewGroup.addView(view,layoutParams0)
            mBinding.autoWrapViewGroup.addView(view)
        }
    }

    companion object {
        const val TAG = "AutoWrapViewGroupActivity"
    }
}